use "build/output/main_panel.dta", clear
tsset coin_id date
sort coin_id date

eststo clear

eststo: reg d_ln_face_bps l.funding_apr i.mdate if coin == "USDT", vce(cluster wdate)
estadd local month_fe "Yes"
estadd local coin_fe "n/a"
estadd local sample "Full"

eststo: reg d_ln_face_bps l.funding_apr l.iv_btc i.mdate if coin == "USDT", vce(cluster wdate)
estadd local month_fe "Yes"
estadd local coin_fe "n/a"
estadd local sample "Full"

eststo: reg d_ln_face_bps l.funding_apr l.iv_btc i.mdate l.d_ln_face_bps l.ln_face l.ln_vol_btc l.d_ln_vol_btc if coin == "USDT", vce(cluster wdate)
estadd local month_fe "Yes"
estadd local coin_fe "n/a"
estadd local sample "Full"

eststo: reg d_ln_face_bps l.funding_apr l.iv_btc i.mdate l.d_ln_face_bps l.ln_face l.ln_vol_btc l.d_ln_vol_btc if coin == "USDT" & mdate !=ym(2022,5), vce(cluster wdate)
estadd local month_fe "Yes"
estadd local coin_fe "n/a"
estadd local sample "Excl. 5/22"


eststo: reg d_ln_face_bps l.funding_apr i.mdate, vce(cluster wdate)
estadd local month_fe "Yes"
estadd local coin_fe "No"
estadd local sample "Full"

eststo: reg d_ln_face_bps l.funding_apr l.iv_btc i.mdate i.coin_id, vce(cluster wdate)
estadd local month_fe "Yes"
estadd local coin_fe "Yes"
estadd local sample "Full"

eststo: reg d_ln_face_bps l.funding_apr l.iv_btc i.mdate i.coin_id l.d_ln_face_bps l.ln_face l.ln_vol_btc l.d_ln_vol_btc, vce(cluster wdate)
estadd local month_fe "Yes"
estadd local coin_fe "Yes"
estadd local sample "Full"

eststo: reg d_ln_face_bps l.funding_apr l.iv_btc i.mdate i.coin_id l.d_ln_face_bps l.ln_face l.ln_vol_btc l.d_ln_vol_btc if mdate !=ym(2022,5), vce(cluster wdate)
estadd local month_fe "Yes"
estadd local coin_fe "Yes"
estadd local sample "Excl. 5/22"


esttab, drop(*.mdate *.coin_id _cons) star(* 0.10 ** 0.05 *** 0.01) r2

esttab using "analysis/output_tables/regression_prop_peg_stability_first_stage.tex", replace booktabs label drop(*.mdate *.coin_id _cons) ///
	mgroups("USDT" "USDT and DAI", pattern(1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	prehead(\begin{tabular}{l S S S S S S S S} \toprule) ///
	posthead(\midrule) postfoot(\bottomrule\end{tabular}) ///
	style(tex) substitute(\_ _) star  b(2) t(2) r2(2) ///
	nomtitles /// 
	varlabels(L.iv_btc "\$\text{Bitcoin Implied Volatility}_{t-1}\$" L.funding_apr "\$\text{Funding Premium}_{t-1}\$" L.d_ln_face_bps "\$\Delta \ln(s_{i,t-1})\$" L.ln_face "\$\ln(s_{i,t-1})\$" L.ln_vol_btc "\$\ln(\text{BTC Volume}_{t-1})\$" L.d_ln_vol_btc "\$\Delta \ln(\text{BTC Volume}_{t-1})\$") /// 
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(N r2 month_fe coin_fe sample, fmt(%9.0fc 2) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}") labels(`"\$N\$"' `"\(R^{2}\)"' `"Month FE"' `"Coin FE"' `"Sample"' ))



	
	